﻿<UserControl x:Class="NuGet.Client.VisualStudio.UI.PackageItemControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             xmlns:ui="clr-namespace:NuGet.Client.VisualStudio.UI"
             xmlns:resx="clr-namespace:NuGet.Client.VisualStudio.UI.Resources"
             MinHeight="80"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ui:PackageStatusToInstallImageVisibilityConverter x:Key="PackageStatusToInstallImageVisibilityConverter" />
        <ui:PackageStatusToUpdateImageVisibilityConverter x:Key="PackageStatusToUpdateImageVisibilityConverter" />
        <ui:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Style x:Key="TooltipStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="MaxWidth" Value="300" />
        </Style>
    </UserControl.Resources>
    <Border
            BorderThickness="0,0,0,1"
            BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
            Padding="0,16,0,15">
        <Grid Margin="24,0,7,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <!-- Icon -->
            <Grid Grid.Column="0" VerticalAlignment="Top">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Image
                    Grid.Row="0"
                    Source="{Binding IconUrl}"
                    Height="32"
                    Width="32"
                    RenderOptions.BitmapScalingMode="HighQuality"                    
                    VerticalAlignment="Top"
                    Margin="0,0,16,0" />

                <TextBlock Grid.Row="1"
                           Text="{x:Static resx:Resources.Label_PackagePrerelease}"
                           FontStyle="Italic"
                           FontSize="9"
                           Margin="0,3,0,0"
                           HorizontalAlignment="Left"
                           Visibility="{Binding Version.IsPrerelease, Converter={StaticResource BooleanToVisibilityConverter}}" />
            </Grid>

            <!-- title & summary-->
            <Grid Grid.Column="1" VerticalAlignment="Top" MinHeight="48">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="32" MaxHeight="32" />
                </Grid.RowDefinitions>
                <TextBlock
                    Grid.Row="0"
                    FontWeight="Bold"
                    TextTrimming="CharacterEllipsis"
                    TextWrapping="NoWrap"
                    AutomationProperties.AutomationId="id"
                    Text="{Binding Id}">
                    <TextBlock.ToolTip>
                        <TextBlock Text="{Binding Id}" Style="{StaticResource TooltipStyle}" />
                    </TextBlock.ToolTip>
                </TextBlock>
                <TextBlock
                    Grid.Row="1"
                    Text="{Binding Summary}"
                    TextTrimming="CharacterEllipsis"
                    TextWrapping="Wrap">
                    <TextBlock.ToolTip>
                        <TextBlock Text="{Binding Summary}" Style="{StaticResource TooltipStyle}" />
                    </TextBlock.ToolTip>
                </TextBlock>
            </Grid>

            <ui:InstalledIndicator
                x:Name="_checkMark"
                Grid.Column="2"
                Margin="16,0,12,0"
                Width="16"
                Height="16"
                VerticalAlignment="Top"
                Visibility="{Binding Status, Converter={StaticResource PackageStatusToInstallImageVisibilityConverter}}"
                ToolTip="{x:Static resx:Resources.Tooltip_PackageInstalled}" />
            <ui:UpdateAvailableIndicator
                x:Name="_updateMark"
                Grid.Column="2"
                Margin="16,0,12,0"
                Width="16"
                Height="16"
                VerticalAlignment="Top"
                Visibility="{Binding Status, Converter={StaticResource PackageStatusToUpdateImageVisibilityConverter}}"
                ToolTip="{x:Static resx:Resources.Tooltip_UpdateAvailable}" />
        </Grid>
    </Border>
</UserControl>